package com.example.bot.thread;

import com.example.bot.ws.Client;
import lombok.SneakyThrows;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class ReconnectTask implements Runnable {

    @SneakyThrows
    @Override
    public void run() {

        while (true) {
            if (Client.connect("ws://127.0.0.1:8088")) {
                break;
            } else {
                Thread.sleep(2 * 1000);
            }
        }
    }

    public static void execute() {
        new Thread(new ReconnectTask()).start();
    }
}
